﻿using System.Web.Mvc;
using SeaBattle.UI.Web.Models;
using System.Web.Security;

namespace SeaBattle.UI.Web.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult LogOn()
        {
            return View(new LogOnModel());
        }

        [HttpPost]
        public ActionResult LogOn(LogOnModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Login == "vasya" ||
                    model.Login == "alex" ||
                    model.Login == "andrew")
                {
                    FormsAuthentication.SetAuthCookie(model.Login, false);
                    return RedirectToAction("Index", "Room");
                }
                ModelState.AddModelError("","Incorrect Login or Password");
            }
            return View(model);
        }

    }
}
